/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author WinKiQue58
 */
@Entity
@Table(name = "POINT_STATUS")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PointStatus.findAll", query = "SELECT p FROM PointStatus p"),
    @NamedQuery(name = "PointStatus.findByIdPointStatus", query = "SELECT p FROM PointStatus p WHERE p.pointStatusPK.idPointStatus = :idPointStatus"),
    @NamedQuery(name = "PointStatus.findByIdPoint", query = "SELECT p FROM PointStatus p WHERE p.pointStatusPK.idPoint = :idPoint"),
    @NamedQuery(name = "PointStatus.findByIdRoute", query = "SELECT p FROM PointStatus p WHERE p.pointStatusPK.idRoute = :idRoute"),
    @NamedQuery(name = "PointStatus.findByName", query = "SELECT p FROM PointStatus p WHERE p.name = :name"),
    @NamedQuery(name = "PointStatus.findByDescription", query = "SELECT p FROM PointStatus p WHERE p.description = :description"),
    @NamedQuery(name = "PointStatus.findByInitdate", query = "SELECT p FROM PointStatus p WHERE p.initdate = :initdate"),
    @NamedQuery(name = "PointStatus.findByEndate", query = "SELECT p FROM PointStatus p WHERE p.endate = :endate")})
public class PointStatus implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected PointStatusPK pointStatusPK;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 180)
    @Column(name = "NAME")
    private String name;
    @Size(max = 180)
    @Column(name = "DESCRIPTION")
    private String description;
    @Basic(optional = false)
    @NotNull
    @Column(name = "INITDATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date initdate;
    @Column(name = "ENDATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date endate;
    @JoinColumns({
        @JoinColumn(name = "ID_POINT", referencedColumnName = "ID_POINT", insertable = false, updatable = false),
        @JoinColumn(name = "ID_ROUTE", referencedColumnName = "ID_ROUTE", insertable = false, updatable = false)})
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Point point;

    public PointStatus() {
    }

    public PointStatus(PointStatusPK pointStatusPK) {
        this.pointStatusPK = pointStatusPK;
    }

    public PointStatus(PointStatusPK pointStatusPK, String name, Date initdate) {
        this.pointStatusPK = pointStatusPK;
        this.name = name;
        this.initdate = initdate;
    }

    public PointStatus(BigInteger idPointStatus, BigInteger idPoint, BigInteger idRoute) {
        this.pointStatusPK = new PointStatusPK(idPointStatus, idPoint, idRoute);
    }

    public PointStatusPK getPointStatusPK() {
        return pointStatusPK;
    }

    public void setPointStatusPK(PointStatusPK pointStatusPK) {
        this.pointStatusPK = pointStatusPK;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Date getInitdate() {
        return initdate;
    }

    public void setInitdate(Date initdate) {
        this.initdate = initdate;
    }

    public Date getEndate() {
        return endate;
    }

    public void setEndate(Date endate) {
        this.endate = endate;
    }

    public Point getPoint() {
        return point;
    }

    public void setPoint(Point point) {
        this.point = point;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (pointStatusPK != null ? pointStatusPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PointStatus)) {
            return false;
        }
        PointStatus other = (PointStatus) object;
        if ((this.pointStatusPK == null && other.pointStatusPK != null) || (this.pointStatusPK != null && !this.pointStatusPK.equals(other.pointStatusPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.PointStatus[ pointStatusPK=" + pointStatusPK + " ]";
    }
    
}
